/**
 * 
 */
package info.niwota.search;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Random;

/**
 * @author qiangli
 * 
 */
public class ProxyService {
	public String uri;
	public boolean encode;

	public ProxyService(String uri, boolean encode) {
		this.uri = uri;
		this.encode = encode;
	}

	public static final ProxyService[] proxies = {
			//new ProxyService("http://anonymouse.org/cgi-bin/anon-www.cgi/", false),
			//new ProxyService("http://www.ghul.net/browse.php?u=", true) 
			};

	private static final Random rand = new Random();

	public static final String getLink(String url)
			throws UnsupportedEncodingException {
		int idx = rand.nextInt(proxies.length);
		ProxyService p = proxies[idx];
		return p.uri + (p.encode ? URLEncoder.encode(url, "UTF-8") : url);
	}
}
